/*
 * igo: com.cctv.igo.admin.scheduler.parser.CronTriggerParser.java Create On 2011-5-3 下午10:42:47 By Q-Wang
 * $Revision: 1.1 $
 */
package com.ctvit.scheduler.parser;

import java.text.ParseException;

import org.quartz.CronTrigger;
import org.quartz.Trigger;

import com.ctvit.scheduler.domain.QrtxTrigger;

/**
 * @author <a href="mailto:apeidou@gmail.com">Q-Wang</a>
 *
 */
public class CronTriggerParser implements TriggerParser {

	/**
	 * @see com.ctvit.scheduler.parser.TriggerParser#parse(QrtxTrigger)
	 */
	@Override
	public Trigger parse(QrtxTrigger source) throws ParseException {
		CronTrigger trigger = new CronTrigger(source.getName(),"DEFAULT",source.getDefinition());
		trigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
		return trigger;
	}

	/**
	 * @see com.ctvit.scheduler.parser.TriggerParser#support(java.lang.String)
	 */
	@Override
	public boolean support(String type) {
		return "CRON".equals(type);
	}

}
